/**
 * @class 彗星实体
 * @author DuskyHuang 圣子
*/
import { _decorator } from 'cc';
import { calcLensBias, } from 'algorithms';
import { planetary } from 'proxies';
import { Orbiter } from './orbiter';
const { ccclass } = _decorator;

@ccclass('cocosmos.Comet')
export class Comet extends Orbiter {

    declare protected _config: cometConfig;
    public get config(): cometConfig { return this._config as cometConfig; }
    protected readonly rotatable: boolean = false;
    protected readonly important: boolean = false;
    protected readonly named: boolean = true;

    public readonly cat = 'comet';
    protected get LODValves(): num.pct[] { return COMET_LOD_VALVES };

    protected step(span: time.sec): void {
        super.step(span);
        this.faceToSun(this._lod0);
        this.faceToSun(this._lod1);
    }
    protected init(): void {
        super.init();
    }

    protected onLod0Initiated(): void { }

    protected configure(): void {
        this._bias = calcLensBias(this.config.diam, SMALLEST, BIGGEST, NEAREST, FARTHEST);
    }

    protected syncLODChoosing(): void {
        super.syncLODChoosing();
        if (planetary.center === this) {
            this._lod0.active = false;
        }
    }
}

const COMET_LOD_VALVES = [0.5, 0.1];

const SMALLEST = 5e-8;  // TO CHECK
const BIGGEST = 20e-8;  // TO CHECK
const NEAREST = 0.2;
const FARTHEST = 0.7;